package com.project.ToDone;

/**
 * Class that does all regex testing for us
 * 
 * @author Matthew Guzdial
 *
 */

public class RegexTester {
	
	
	/**
	 * Checks that string isn't nothing, returns true if so.
	 * 
	 * @param text
	 * @return
	 */
	public boolean stringNotNullTest(String text){
		boolean result=true;
		if(text.equals("")){
			result=false;
		}
		return result;
	}

	/**
	 * Makes sure date matches our format, returns true if so
	 * 
	 * @param date
	 * @return
	 */
	public boolean dateTest(String date){
		boolean result = true;
		//Doesn't pass test
		if(!date.matches("[0|1][0-9]/[0-3][0-9]/[0-9]{2}")){
			return false;
		}
		return result;
	}
	
	/**
	 * Makes sure time matches our format, returns true if so
	 * 
	 * @param time
	 * @return
	 */
	public boolean timeTest(String time){
		boolean result = true;
		if(!time.matches("[0-9]{2}:[0-9]{2}")){
			return false;
		}
		return result;
	}
	
	/**
	 * Makes sure email matches our format, returns true if so
	 * 
	 * @param email
	 * @return
	 */
	public boolean emailTest(String email){
		boolean result=false;
		if(email.matches("[A-Z|a-z|0-9][A-Z|a-z|0-9]*@[A-Z|a-z|0-9]*.(com|org|net|edu)")){
			return true;
		}
		return result;
	}
	
	/**
	 * Make sure name matches our format (both names required), returns true if so
	 * 
	 * @param name
	 * @return
	 */
	public boolean nameTest(String name){
		boolean result =false;
		
		if(name.matches("[A-Z][a-z|\\-|A-Z]*[ ][A-Z][A-Z]?[a-z|\\-|A-Z]*")){
			return true;
		}
		return result;
		
	}
	
	/**
	 * Makes sure the address matches our US Postal Service address, returns true if so
	 * 
	 * @param address
	 * @return
	 */
	public boolean addressTest(String address){
		boolean result=false;
		
		if(address.matches("[\\d][\\d]?[\\d]?[\\d]?[\\d]?[ ][A-Z|a-z|\\.|\\-| ]*[,][ ][A-Z][A-Z][ ][\\d]{5}")){
			result=true;
		}
		return result;
	}
	
	/**
	 * Makes sure the username matches our specifications, returns true if so
	 * 
	 * @param password
	 * @return
	 */
	public boolean usernameTest(String password){
		boolean result =false;
		
		if(password.matches("([\\w]|[\\d])([\\w]|[\\d])*")){
			result=true;
		}
		return result;
		
	}
}
